package com.haoshuang.zhouzhoubang.ui.vm

import androidx.lifecycle.rxLifeScope
import com.haoshuang.zhouzhoubang.base.request
import com.haoshuang.zhouzhoubang.model.bean.CompleteOrderListBean
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData


class OrderWcViewModel : BaseViewModel() {

    /**
     * 获取完成订单列表
     */
    val getCompleteOrderListData = StatefulMutableLiveData<CompleteOrderListBean>()
    fun getCompleteOrderList(vararg params: Pair<String, Any?>) {
        rxLifeScope.launch {
            request<CompleteOrderListBean>("api/master/get_Team_complete_order_list", *params,
                onStart = {
                    getCompleteOrderListData.value = StateData.Loading
                },
                onError = { code, msg ->
                    getCompleteOrderListData.value = StateData.Error(code, msg)
                }, onSuccess = {
                    getCompleteOrderListData.value = StateData.Success(it)
                })
        }
    }

}